from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC  # 起个别名
from time import sleep
from options import options
from service import service

dr=webdriver.Chrome(options=options,service=service)
dr.get(r'https://www.baidu.com/')
dr.maximize_window()

# 鼠标悬停在设置上
ele=dr.find_element(By.ID,'s-usersetting-top')
ActionChains(dr).move_to_element(ele).perform()
sleep(3)
# 搜索设置
dr.find_element(By.XPATH,'//*[@id="s-user-setting-menu"]/div/a[1]/span').click()
sleep(1)
# 高级搜索
dr.find_element(By.XPATH,'//*[@id="wrapper"]/div[6]/div/div/ul/li[2]').click()
sleep(1)
# 时间不限下拉框
dr.find_element(By.XPATH,'//*[@id="adv-setting-gpc"]/div/div[1]/span').click()
sleep(1)
# 一周内
# dr.find_element(By.XPATH,'//*[@id="adv-setting-gpc"]/div/div[2]/div[2]/p[3]').click()
# sleep(1)
# 通过找到父级唯一属性，再定位菜单值
ele = dr.find_element(By.ID, 'adv-setting-gpc')
ele.find_elements(By.XPATH, '//p[@class="c-select-item"]')[2].click()
sleep(1)
dr.quit()